home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / Little Smalltalk v3.1.4 / C Source / Sources / CSelectPane.cp < prev    next >
Text File  |  1995-01-31  |  2KB  |  69 lines

  1. //=============================================================================
  2. //    Little Smalltalk, version 3
  3. //    Written by Tim Budd, Oregon State University, July 1988
  4. //
  5. //    Symantec Think Class Library interface code 
  6. //        ⌐Julian Barkway, April 1994, all rights reserved. 
  7. //
  8. //    CSelectPane.cp
  9. //    --------------
  10. //    Methods for a text editing pane which only allows selections.
  11. //
  12. //=============================================================================
  13.  
  14.  
  15. #include "CSelectPane.h"
  16. #include "CPaneBorder.h"
  17. #include "CWindow.h"
  18. #include "CDocument.h"
  19. #include "Constants.h"
  20. #include <global.h>
  21.  
  22. extern     EventRecord  gLastMouseUp;
  23. extern     CBureaucrat    *gGopher;    
  24.  
  25.  
  26. //={OVERRIDE}==================================================================
  27. // Initialise a shiny new select pane object.
  28. //=============================================================================
  29. void CSelectPane::ISelectPane (CView *encl, CBureaucrat *super, 
  30.                                 SizingOption hSizing, SizingOption vSizing,
  31.                                 short lineLength)
  32. {
  33.     Rect        margin = {4, 4, 0, 0};
  34.     
  35.     IEditText      (encl, super, 1, 1, 0, 0, hSizing, vSizing, 2000);
  36.     FitToEnclosure (TRUE, TRUE);
  37.     ResizeFrame    (&margin);
  38.     Specify          (kNotEditable, kSelectable, kStylable);
  39. }
  40.  
  41.  
  42. //={OVERRIDE}==================================================================
  43. // Null function because we want to maintain selection when user switches panes
  44. //=============================================================================
  45. void CSelectPane::Deactivate (void)
  46. {
  47. }
  48.  
  49.  
  50. //={OVERRIDE}==================================================================
  51. // Select one full line with single click
  52. //=============================================================================
  53. void CSelectPane::DoClick (Point hitPt, short modifierKeys, long when)
  54. {
  55.     TEHandle    teh;
  56.     LongPt        lp;
  57.     short        ln, startPos, endPos;
  58.     
  59.     if (modifierKeys & optionKey)    // No selection when option key pressed
  60.         return;
  61.  
  62.     teh = this->macTE;
  63.     QDToLongPt(hitPt, &lp);
  64.     ln = FindLine (GetCharOffset (&lp));
  65.     startPos = (*teh)->lineStarts [ln];
  66.     endPos   = (*teh)->lineStarts [ln + 1];
  67.     SetSelection (startPos, endPos, TRUE);
  68. }
  69.